package com.ss.android.article.base.feature.feed.vh;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.ColorFilter;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bytedance.article.common.c.TTUtils;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.UIUtils;
import com.ss.android.account.Spipe;
import com.ss.android.action.b.FeedViewHolder;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.app.b.DBHelper;
import com.ss.android.article.base.feature.c.FeedItemBehavior;
import com.ss.android.article.base.feature.feed.FeedOnMovedToScrapHeapListener;
import com.ss.android.article.base.feature.feed.activity.InfoLayout;
import com.ss.android.article.base.feature.feed.k;
import com.ss.android.article.base.feature.model.Article;
import com.ss.android.article.base.feature.model.CellRef;
import com.ss.android.article.base.feature.model.DownloadAppAd;
import com.ss.android.article.base.feature.model.FeedCallAppAd;
import com.ss.android.article.base.ui.DuplicatePressedRelativeLayout;
import com.ss.android.article.base.utils.ArticleHelper;
import com.ss.android.article.browser.R;
import com.ss.android.article.common.NightModeAsyncImageView;
import com.ss.android.common.ad.MobAdClickCombiner;
import com.ss.android.common.download.DownloadAdapterProxy;
import com.ss.android.common.download.DownloadInfoChangeListener;
import com.ss.android.common.download.DownloadShortInfo;
import com.ss.android.common.ui.view.UnPressableRelativeLayout;
import com.ss.android.common.util.ToolUtils;
import com.ss.android.image.AsyncImageView;
import com.ss.android.image.AvatarLoader;
import com.ss.android.image.model.ImageInfo;
import com.ss.android.j.ClickableBackgroundCompat;
import com.ss.android.newmedia.util.AppUtil;

import org.json.JSONObject;

import java.util.concurrent.atomic.AtomicBoolean;

public final class AdItemInVideoFeedViewHolder extends FeedViewHolder implements k, FeedOnMovedToScrapHeapListener {
    final class a implements DownloadInfoChangeListener {
        public final AdItemInVideoFeedViewHolder b;
        long a;

        a(AdItemInVideoFeedViewHolder arg1) {
            this.b = arg1;
        }

        public final void setDownloadId(long id) {
            this.a = id;
        }

        public final void onDownloadProgressChanged(final DownloadShortInfo downloadShortInfo, final int arg11, final long arg12, final long arg14, long arg16) {
            this.b.mRoot.post(new Runnable() {

                public final void run() {
                    long v6_1;
                    int v6 = 8;
                    int v5 = 2;
                    if (downloadShortInfo != null && downloadShortInfo.id == AdItemInVideoFeedViewHolder.a.this.a) {
                        Logger.d("AppAdViewHolder", "mId = " + AdItemInVideoFeedViewHolder.a.this.a
                                + " info.id = " + downloadShortInfo.id
                                + " fileName = " + downloadShortInfo.fileName);
                        try {
                            AdItemInVideoFeedViewHolder.a.this.b.B = downloadShortInfo;
                            String v0_1 = "";
                            AdItemInVideoFeedViewHolder.a.this.b.mAppAdProgress.setVisibility(View.VISIBLE);
                            AdItemInVideoFeedViewHolder.a.this.b.mAdBtnLayout.setVisibility(View.VISIBLE);
                            if (arg11 == 1) {
                                Logger.d("AppAdViewHolder", "mAppAd.mId = " + AdItemInVideoFeedViewHolder.a.this.b.J.id + ", status == DownloadNotifier.TYPE_ACTIVE");
                                v0_1 = AdItemInVideoFeedViewHolder.a.this.b.mResources.getString(com.ss.android.article.browser.R.string.kf);
                                UIUtils.setBackgroundResource(AdItemInVideoFeedViewHolder.a.this.b.mAdBtnLayout, R.color.transparent);
                                AdItemInVideoFeedViewHolder.a.this.b.b(com.ss.android.article.browser.R.color.ssxinzi8);
                            } else if (arg11 == v5) {
                                Logger.d("AppAdViewHolder", "mAppAd.mId = " + AdItemInVideoFeedViewHolder.a.this.b.J.id + ", status == DownloadNotifier.TYPE_WAITING");
                                v0_1 = AdItemInVideoFeedViewHolder.a.this.b.mResources.getString(com.ss.android.article.browser.R.string.ki);
                                UIUtils.setBackgroundResource(AdItemInVideoFeedViewHolder.a.this.b.mAdBtnLayout, R.color.transparent);
                                AdItemInVideoFeedViewHolder.a.this.b.b(com.ss.android.article.browser.R.color.ssxinzi8);
                                com.ss.android.article.base.feature.b.a v1 = android.support.design.a.c(AdItemInVideoFeedViewHolder.a.this.b.J.id);
                                if (v1 != null) {
                                    v1.c += System.currentTimeMillis() - v1.b;
                                    v1.b = System.currentTimeMillis();
                                    android.support.design.a.a(v1, false);
                                }
                            } else if (arg11 == 3) {
                                Logger.d("AppAdViewHolder", "mAppAd.mId = " + AdItemInVideoFeedViewHolder.a.this.b.J.id + ", status == DownloadNotifier.TYPE_COMPLETE");
                                AdItemInVideoFeedViewHolder.a.this.b.mAppAdProgress.setVisibility(View.GONE);
                                if (AdItemInVideoFeedViewHolder.a.this.b.B.b == 16) {
                                    com.ss.android.article.base.feature.b.a v0_2 = android.support.design.a.c(AdItemInVideoFeedViewHolder.a.this.b.J.id);
                                    Logger.d("AppAdViewHolder", "mAppAd.mId = " + AdItemInVideoFeedViewHolder.a.this.b.J.id + ", download fail");
                                    if (v0_2 != null) {
                                        v6_1 = System.currentTimeMillis() - v0_2.b + v0_2.c;
                                        String v1_1 = AdItemInVideoFeedViewHolder.a.this.b.a(AdItemInVideoFeedViewHolder.a.this.b.B.id);
                                        JSONObject jsonObject = new JSONObject();
                                        jsonObject.put("fail_status", v1_1);
                                        jsonObject.put("duration", v6_1);
                                        jsonObject.put("log_extra", AdItemInVideoFeedViewHolder.a.this.b.J.logExtra);
                                        Logger.d("AppAdViewHolder", "mAppAd.mId = " + AdItemInVideoFeedViewHolder.a.this.b.J.id + ", download fail, duration = " + v6_1 + ", failedReason = " + v1_1);
                                        MobAdClickCombiner.onAdEvent(AdItemInVideoFeedViewHolder.a.this.b.mContext, "feed_download_ad", "download_fail", AdItemInVideoFeedViewHolder.a.this.b.J.id, v6_1, jsonObject, 2);
                                        android.support.design.a.a(v0_2, true);
                                    }

                                    v0_1 = AdItemInVideoFeedViewHolder.a.this.b.mResources.getString(com.ss.android.article.browser.R.string.kh);
                                    UIUtils.setBackgroundResource(AdItemInVideoFeedViewHolder.a.this.b.mAdBtnLayout, R.drawable.ag);
                                    AdItemInVideoFeedViewHolder.a.this.b.b(com.ss.android.article.browser.R.color.d1);
                                } else {
                                    if (AdItemInVideoFeedViewHolder.a.this.b.B.b != v6) {
                                    } else {

                                        if (!ToolUtils.d(AdItemInVideoFeedViewHolder.a.this.b.mContext, AdItemInVideoFeedViewHolder.a.this.b.B.fileName)) {
                                            v0_1 = AdItemInVideoFeedViewHolder.a.this.b.mResources.getString(com.ss.android.article.browser.R.string.k9);
                                        } else if (!android.support.design.a.isTextEmpty(AdItemInVideoFeedViewHolder.a.this.b.J.btnTxt)) {
                                            v0_1 = AdItemInVideoFeedViewHolder.a.this.b.J.btnTxt;
                                        } else {
                                            v0_1 = AdItemInVideoFeedViewHolder.a.this.b.mResources.getString(com.ss.android.article.browser.R.string.ke);
                                        }

                                        AdItemInVideoFeedViewHolder.a.this.b.b(com.ss.android.article.browser.R.color.cx);
                                        UIUtils.setBackgroundResource(AdItemInVideoFeedViewHolder.a.this.b.mAdBtnLayout, R.drawable.ae);
                                        com.ss.android.article.base.feature.b.a v10 = android.support.design.a.c(AdItemInVideoFeedViewHolder.a.this.b.J.id);
                                        if (v10 == null) {
                                        } else {
                                            v6_1 = System.currentTimeMillis() - v10.b + v10.c;
                                            Logger.d("AppAdViewHolder", "mAppAd.mId = " + AdItemInVideoFeedViewHolder.a.this.b.J.id + ", download success, duration = " + v6_1);
                                            MobAdClickCombiner.onAdEvent(AdItemInVideoFeedViewHolder.a.this.b.mContext, "feed_download_ad", "download_success", AdItemInVideoFeedViewHolder.a.this.b.J.id, v6_1, AdItemInVideoFeedViewHolder.a.this.b.J.logExtra, 2);
                                            android.support.design.a.a(v10, true);
                                        }
                                    }
                                }

                                AdItemInVideoFeedViewHolder.a.this.b.mAppAdProgress.setVisibility(View.GONE);
                            }

                            if (arg12 > 0) {
                                AdItemInVideoFeedViewHolder.a.this.b.mAppAdProgress.setProgress(((int) (arg14 * 100 / arg12)));
                            } else {
                                AdItemInVideoFeedViewHolder.a.this.b.mAppAdProgress.setProgress(0);
                            }

                            if (AdItemInVideoFeedViewHolder.a.this.b.mAdBtnLayout.getVisibility() != View.VISIBLE) {
                                return;
                            }

                            AdItemInVideoFeedViewHolder.a.this.b.mAdTv.setText(((CharSequence) v0_1));
                        } catch (Exception v0) {
                            v0.printStackTrace();
                        }
                    }
                }
            });
        }
    }

    public final class b extends AsyncTask {
        private final AdItemInVideoFeedViewHolder a;

        public b(AdItemInVideoFeedViewHolder arg1) {
            this.a = arg1;

        }

        protected final Object doInBackground(Object[] arg7) {
            Object v0_1 = null;
            if (arg7 != null) {
                if (arg7.length > 0 && (TextUtils.isEmpty((CharSequence) arg7[0]))) {
                    return null;
                }

                if (mContext == null) {
                    return null;
                }

                Object v1 = arg7[0];
                DownloadShortInfo result = DownloadAdapterProxy.inst().queryDownloadInfo(mContext, ((String) v1));
                if (result == null) {
                    return result;
                }
                Logger.d("AppAdViewHolder queryDownloadInfo", "result.id = " + result.id + " url = " + v1 + " fileName = " + result.fileName);
            } else {
                label_10:
                v0_1 = null;
            }

            return v0_1;
        }

        protected final void onPostExecute(Object arg9) {
            String v0_3 = null;
            int v0_4;
            Resources v2;
            TextView v1;
            super.onPostExecute(arg9);
            if (!this.isCancelled()) {
                try {
                    boolean v0_1 = AppUtil.a(mContext, J.version, J.pkg);
                    if ((AppData.getInstance().allowInsideDownloadManager()) && arg9 != null && ((DownloadShortInfo) arg9).id > -1 && !DownloadAdapterProxy.inst().isDownloadSuccessAndFileNotExist(mContext, ((DownloadShortInfo) arg9)) && !v0_1) {
                        if (arg9 != null) {
                            Logger.d("AppAdViewHolder QueryDownloadInfoTask", "result.id = " + ((DownloadShortInfo) arg9).id + " fileName = " + ((DownloadShortInfo) arg9).fileName);
                            DownloadAdapterProxy.inst().registerDownloadListener(mContext, Long.valueOf(((DownloadShortInfo) arg9).id), N, String.valueOf(J.id), 1, J.logExtra);
                        }

                        B = ((DownloadShortInfo) arg9);
                        mAppAdProgress.setVisibility(View.VISIBLE);
                        switch (((DownloadShortInfo) arg9).b) {
                            case 1:
                            case 2: {
                                String v7 = mResources.getString(com.ss.android.article.browser.R.string.kf);
                                UIUtils.setBackgroundResource(mAdBtnLayout, com.ss.android.article.browser.R.color.transparent);
                                b(com.ss.android.article.browser.R.color.ssxinzi8);
                                DownloadAdapterProxy.inst().registerDownloadListener(mContext, Long.valueOf(((DownloadShortInfo) arg9).id), N, String.valueOf(J.id), 1, J.logExtra);
                                v0_3 = v7;
                                break;
                            }
                            case 4: {
                                v0_3 = mResources.getString(com.ss.android.article.browser.R.string.ki);
                                UIUtils.setBackgroundResource(mAdBtnLayout, com.ss.android.article.browser.R.color.transparent);
                                b(com.ss.android.article.browser.R.color.ssxinzi8);
                                break;
                            }
                            case 8: {
                                if (ToolUtils.d(mContext, ((DownloadShortInfo) arg9).fileName)) {
                                    v0_3 = mResources.getString(com.ss.android.article.browser.R.string.ke);
                                } else {
                                    v0_3 = mResources.getString(com.ss.android.article.browser.R.string.k9);
                                }
                                b(com.ss.android.article.browser.R.color.cx);
                                UIUtils.setBackgroundResource(mAdBtnLayout, com.ss.android.article.browser.R.drawable.ae);
                                mAppAdProgress.setVisibility(View.GONE);
                                break;
                            }
                            case 16: {
                                mAppAdProgress.setVisibility(View.GONE);
                                v0_3 = mResources.getString(com.ss.android.article.browser.R.string.kh);
                                UIUtils.setBackgroundResource(mAdBtnLayout, com.ss.android.article.browser.R.drawable.ag);
                                b(com.ss.android.article.browser.R.color.d1);
                                break;
                            }
                        }
                        if (((DownloadShortInfo) arg9).c > 0) {
                            mAppAdProgress.setProgress(((int) (((DownloadShortInfo) arg9).d * 100 / ((DownloadShortInfo) arg9).c)));
                        } else {
                            mAppAdProgress.setProgress(0);
                        }

                        mAdTv.setText(((CharSequence) v0_3));
                    } else {
                        if (B != null) {
                            DownloadAdapterProxy.inst().unregisterDownloadListener(mContext, Long.valueOf(B.id), N);
                        }

                        B = null;
                        v1 = mAdTv;
                        v2 = mResources;
                        v0_4 = v0_1 ? com.ss.android.article.browser.R.string.kj : com.ss.android.article.browser.R.string.ka;
                        v1.setText(v2.getString(v0_4));
                        mAdBtnLayout.setBackgroundResource(com.ss.android.article.browser.R.drawable.ad_action_btn_begin_bg);
                        b(com.ss.android.article.browser.R.color.ad_action_btn_begin_text_color);
                        mAppAdProgress.setVisibility(View.GONE);
                    }
                } catch (Exception v0) {
                }
            }
        }
    }

    public TextView mAdLabel;
    public DownloadShortInfo B;
    public RelativeLayout mAdBtnLayout;
    public ProgressBar mAppAdProgress;
    public TextView mAdTv;
    public View mCoverTopShaow;
    public InfoLayout mInfoLayoutGroup;
    protected Context mContext;
    protected final Resources mResources;
    protected DownloadAppAd J;
    protected FeedCallAppAd K;
    public CellRef mCellRef;
    public boolean M = false;
    public final a N = new a(this);
    private int O = -1;
    private AppData mAppData;
    private FeedItemBehavior Q;
    private Article mArticle;
    private String S;
    private AtomicBoolean T;
    private boolean U;
    private int V = -1;
    private int W;
    private int X;
    private boolean Y;
    private b Z;
    private ColorFilter aa;
    private ViewTreeObserver.OnPreDrawListener mOnPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {

        public final boolean onPreDraw() {
            mContentWrapper.getViewTreeObserver().removeOnPreDrawListener(((ViewTreeObserver.OnPreDrawListener) this));
            return true;
        }
    };
    private View.OnClickListener ac = new View.OnClickListener() {

        public final void onClick(View arg3) {
            a(2);
        }
    };
    private View.OnClickListener ad = new View.OnClickListener() {
        public final void onClick(View v) {
            Context context = mContext;
            CellRef cellRef = mCellRef;
            if (context != null && cellRef != null) {
                DBHelper dbHelper = DBHelper.getInstance(context);
                if (dbHelper != null) {
                    long now = System.currentTimeMillis();
                    cellRef.appendReadTs(now);
                    if (cellRef.cellType == 0) {
                        Article article = cellRef.article;
                        if (article != null) {
                            article.clickTimestamp = now;
                            dbHelper.syncReadTs(article);
                        }
                    } else {
                        dbHelper.a(cellRef);
                    }
                }
            }
            a(v);
        }
    };
    private View.OnClickListener ae = new View.OnClickListener() {
        public final void onClick(View arg11) {
            if (K != null && mContext != null) {
                JSONObject jsonObject = new JSONObject();
                try {
                    if (!android.support.design.a.isTextEmpty(K.logExtra)) {
                        jsonObject.put("log_extra", K.logExtra);
                    }

                    MobAdClickCombiner.onAdEvent(mContext, "embeded_ad", "click", K.id, 2, jsonObject, 2);
                } catch (Exception v0) {
                }

                if (K.actionType != 1) {
                    return;
                }

                if (!android.support.design.a.isTextEmpty(K.phoneNumber)) {
                    try {
                        MobAdClickCombiner.onAdEvent(mContext, "feed_call", "click_call", K.id, ((long) K.actionType), jsonObject, 2);
                        ToolUtils.e(mContext, K.phoneNumber);
                    } catch (Exception v0) {
                    }
                }
            }
        }
    };
    public AvatarLoader mAvatarLoader;
    public DuplicatePressedRelativeLayout mRoot;
    public ViewGroup mContentWrapper;
    public View mDelete;
    public ImageView mDivider;
    public RelativeLayout mAdLargeImageLayout;
    public AsyncImageView mLargeImage;
    public TextView mAdTitle;
    public UnPressableRelativeLayout mAdBottomLayout;
    public ImageView mAdAvatar;
    public TextView mAdAvatarTv;
    public TextView mAdSourceTvName;

    public AdItemInVideoFeedViewHolder(Context context, FeedItemBehavior arg4, int arg5, int arg6, AtomicBoolean arg7) {
        this.mContext = context;
        this.Q = arg4;
        Spipe.inst();
        this.mAppData = AppData.getInstance();
        this.mResources = this.mContext.getResources();
        this.X = arg5;
        context.getResources().getDimensionPixelSize(com.ss.android.article.browser.R.dimen.hp);
        context.getResources().getDimensionPixelSize(com.ss.android.article.browser.R.dimen.hq);
        this.W = arg6;
        this.T = arg7;
    }

    private static void a(View arg0, View.OnClickListener arg1) {
        if (arg0 != null && arg1 != null) {
            arg0.setOnClickListener(arg1);
        }
    }

    private void a(AsyncImageView arg5, ImageInfo arg6) {
        if (arg6 != null && (arg6.isValid()) && arg5 != null) {
            android.support.design.a.setImage(arg5, arg6);
            arg5.setTag(com.ss.android.article.browser.R.id.image_info, null);
            UIUtils.setLayoutParams(((View) arg5), -3, ArticleHelper.getActualLargeImageHeight(arg6, this.X, true, this.W));
            UIUtils.setVisibility(((View) arg5), 0);
        }

        if (!this.T.get()) {
            this.loadImage();
            this.U = false;
        } else {
            this.U = true;
        }
    }

    private void a(String arg3, int arg4) {
        if (android.support.design.a.isTextEmpty(arg3)) {
            arg3 = this.mResources.getString(com.ss.android.article.browser.R.string.ad_label_new);
        }

        if (this.mAdLabel != null) {
            UIUtils.setVisibility(this.mAdLabel, 0);
            android.support.design.a.a(this.mContext, this.mAdLabel, arg4, arg3);
        }
    }

    private void a(String arg6, String arg7, String arg8, String arg9) {
        if (this.mAdTitle != null && !android.support.design.a.isTextEmpty(arg6)) {
            UIUtils.setText(this.mAdTitle, ((CharSequence) arg6));
            UIUtils.setVisibility(this.mAdTitle, 0);
        }

        if (this.mAdTv != null) {
            if (!android.support.design.a.isTextEmpty(arg7)) {
                UIUtils.setText(this.mAdTv, ((CharSequence) arg7));
            } else if (this.O == 1) {
                UIUtils.setText(this.mAdTv, this.mResources.getString(com.ss.android.article.browser.R.string.ka));
            } else if (this.O == 2) {
                UIUtils.setText(this.mAdTv, this.mResources.getString(com.ss.android.article.browser.R.string.k8));
            } else if (this.O == 0) {
                UIUtils.setText(this.mAdTv, this.mResources.getString(com.ss.android.article.browser.R.string.ad_label_detail));
            }

            UIUtils.setVisibility(this.mAdBtnLayout, 0);
            if (this.O != 1) {
                this.mAdBtnLayout.setBackgroundResource(com.ss.android.article.browser.R.drawable.ad_action_btn_begin_bg);
                UIUtils.setVisibility(this.mAppAdProgress, 8);
                this.mAdTv.setTextColor(ContextCompat.getColor(this.mContext, com.ss.android.article.browser.R.color.ssxinzi5));
                this.mAdTv.setTextSize(14f);
            }

            if (this.mAdSourceTvName != null && !android.support.design.a.isTextEmpty(arg8)) {
                UIUtils.setText(this.mAdSourceTvName, arg8);
            }

            if (this.mAdAvatar != null && !android.support.design.a.isTextEmpty(arg9)) {
                UIUtils.setVisibility(this.mAdAvatar, 0);
                this.mAvatarLoader.loadAvatar(this.mAdAvatar, arg9);
                if (this.M) {
                    this.mAdAvatar.setColorFilter(this.aa);
                } else {
                }

                return;
            }

            if (this.mAdAvatarTv == null) {
                return;
            }

            if (android.support.design.a.isTextEmpty(arg8)) {
                return;
            }

            UIUtils.setVisibility(this.mAdAvatarTv, 0);
            UIUtils.setText(this.mAdAvatarTv, arg8.substring(0, 1));
            android.support.design.a.b(this.mAdAvatarTv, this.mCellRef.sourceIconStyle);
        }
    }

    public final String a(long arg4) {
        return DownloadAdapterProxy.inst().getFailedReson(this.mContext, arg4);
    }

    final void a(int arg9) {
        DownloadShortInfo v3 = null;
        if (this.J != null) {
            this.J.J = System.currentTimeMillis();
            if (AppData.getInstance().allowInsideDownloadManager()) {
                this.J.a(this.mContext, arg9, this.B, this.N, 1);
            } else {
                this.J.a(this.mContext, arg9, v3, ((DownloadInfoChangeListener) null), 1);
            }
        }
    }

    public final void a(View arg4) {
        if (this.O == 1) {
            this.a(1);
        } else if (this.Q != null) {
            this.Q.handleItemClick(this.V, arg4, new Object[0]);
        }
    }

    public final void a(CellRef arg9, int arg10) {
        ColorFilter v1 = null;
        int v7 = 2;
        int v6 = -3;
        if (arg9 != null) {
            if (arg9.cellType == 0 && arg9.Q == 3) {
                this.O = v7;
            } else if (arg9.cellType == 10) {
                this.O = 1;
            } else if (arg9.cellType != 0) {
                return;
            } else if (arg9.Q == 0) {
                this.O = 0;
            } else {
                return;
            }

            if (this.Y) {
                Logger.throwException("status dirty ! This should not occur !");
                this.onMovedToScrapHeap();
            }

            this.Y = true;
            this.mCellRef = arg9;
            this.V = arg10;
            if (this.M != AppData.isNightMode()) {
                this.M = AppData.isNightMode();
                ColorFilter v0 = this.M ? TTUtils.getNightModeColorFilter() : v1;
                this.aa = v0;
                ClickableBackgroundCompat.setClickableBackground(this.mRoot, this.M);
                this.mDivider.setBackgroundColor(ContextCompat.getColor(this.mContext, com.ss.android.article.browser.R.color.divider));
                this.g();
            }

            if (this.mCellRef != null) {
                this.mDivider.setVisibility(View.VISIBLE);
                this.M = AppData.isNightMode();
                if (this.M) {
                    v1 = TTUtils.getNightModeColorFilter();
                }

                this.aa = v1;
                this.J = this.mCellRef.downloadAppAd;
                this.K = this.mCellRef.feedCallAppAd;
                this.mArticle = this.mCellRef.article;
                this.S = this.mCellRef.sourceAvatar;
                if (this.mContentWrapper != null) {
                    this.mAdLargeImageLayout = this.mContentWrapper.findViewById(com.ss.android.article.browser.R.id.ad_large_image_layout);
                    if (this.mAdLargeImageLayout != null) {
                        this.mLargeImage = this.mAdLargeImageLayout.findViewById(com.ss.android.article.browser.R.id.large_image);
                        this.mAdTitle = this.mAdLargeImageLayout.findViewById(com.ss.android.article.browser.R.id.ad_title);
                        this.mCoverTopShaow = this.mAdLargeImageLayout.findViewById(com.ss.android.article.browser.R.id.cover_top_shaow);
                    }

                    this.mAdBottomLayout = this.mContentWrapper.findViewById(com.ss.android.article.browser.R.id.ad_bottom_layout);
                    if (this.mAdBottomLayout != null) {
                        this.mAdAvatar = this.mAdBottomLayout.findViewById(com.ss.android.article.browser.R.id.ad_avatar);
                        this.mAdAvatarTv = this.mAdBottomLayout.findViewById(com.ss.android.article.browser.R.id.ad_avatar_tv);
                        this.mAdSourceTvName = this.mAdBottomLayout.findViewById(com.ss.android.article.browser.R.id.ad_source_tv_name);
                        this.mAdSourceTvName.setMaxWidth(((int) UIUtils.dp2px(this.mContext, 150f)));
                        this.mAdLabel = this.mAdBottomLayout.findViewById(com.ss.android.article.browser.R.id.ad_label);
                    }

                    this.mAdBtnLayout = this.mContentWrapper.findViewById(com.ss.android.article.browser.R.id.ad_btn_layout);
                    if (this.mAdBottomLayout != null) {
                        this.mAppAdProgress = this.mAdBtnLayout.findViewById(com.ss.android.article.browser.R.id.app_ad_progress);
                        this.mAdTv = this.mAdBtnLayout.findViewById(com.ss.android.article.browser.R.id.ad_tv);
                    }

                    this.mInfoLayoutGroup = this.mContentWrapper.findViewById(com.ss.android.article.browser.R.id.info_layout_group);
                }

                if (this.M) {
                    this.g();
                }

                if (this.mAdLargeImageLayout != null) {
                    UIUtils.setVisibility(this.mAdLargeImageLayout, 0);
                }

                if (this.mCoverTopShaow != null) {
                    UIUtils.setVisibility(this.mCoverTopShaow, 0);
                }

                if (this.mCellRef != null) {
                    if (this.mDivider != null) {
                        UIUtils.setLayoutMargins(this.mDivider, 0, v6, 0, v6);
                        UIUtils.setLayoutParams(this.mDivider, v6, ((int) UIUtils.dp2px(this.mContext, 11f)));
                        this.mDivider.setBackgroundResource(com.ss.android.article.browser.R.color.ssxinxian1);
                        this.mDivider.setImageResource(com.ss.android.article.browser.R.color.ssxinmian3);
                        int v0_1 = ((int) UIUtils.dp2px(this.mContext, 0.5f));
                        this.mDivider.setPadding(0, v0_1, 0, v0_1);
                    }

                    if (this.O == 0) {
                        if (this.mArticle == null) {
                        } else {
                            this.a(this.mCellRef.adLabel, this.mCellRef.labelStyle);
                            this.a(this.mLargeImage, this.mArticle.largeImageList);
                            this.a(this.mArticle.title, this.mResources.getString(com.ss.android.article.browser.R.string.ad_label_detail), this.mArticle.source, this.S);
                        }
                    } else if (this.O == v7) {
                        if (this.K == null) {
                        } else {
                            this.a(this.K.appAdSourceLabel, this.mCellRef.labelStyle);
                            this.a(this.mLargeImage, this.K.imageInfo);
                            this.a(this.K.appAdTitle, this.K.btnText, this.K.appAdSource, this.S);
                        }
                    } else if (this.O != 1) {
                    } else if (this.J == null) {
                    } else {
                        this.a(this.J.appAdSourceLabel, this.mCellRef.labelStyle);
                        this.a(this.mLargeImage, this.J.imageInfo);
                        this.a(this.J.appAdTitle, this.J.btnTxt, this.J.appName, this.S);
                        UIUtils.setVisibility(this.mAppAdProgress, 0);
                    }
                }

                if (this.O == v7) {
                    AdItemInVideoFeedViewHolder.a(this.mRoot, this.ad);
                    AdItemInVideoFeedViewHolder.a(this.mAdBtnLayout, this.ae);
                } else if (this.O == 1) {
                    AdItemInVideoFeedViewHolder.a(this.mRoot, this.ad);
                    AdItemInVideoFeedViewHolder.a(this.mAdBtnLayout, this.ac);
                } else if (this.O == 0) {
                    AdItemInVideoFeedViewHolder.a(this.mRoot, this.ad);
                    AdItemInVideoFeedViewHolder.a(this.mAdBtnLayout, this.ad);
                }

                if (this.O != 1) {
                } else if (AppData.getInstance().allowInsideDownloadManager()) {
                    if (this.B != null) {
                        DownloadAdapterProxy.inst().unregisterDownloadListener(this.mContext, Long.valueOf(this.B.id), this.N);
                    }

                    if (this.Z != null && this.Z.getStatus() != AsyncTask.Status.FINISHED) {
                        this.Z.cancel(true);
                    }

                    this.Z = new b(this);
                    com.bytedance.common.utility.b.a.a(this.Z, new String[]{this.J.downloadUrl});
                } else {
                    UIUtils.setVisibility(this.mAppAdProgress, 8);
                    UIUtils.setBackgroundResource(this.mAdBtnLayout, com.ss.android.article.browser.R.drawable.am);
                }
            }

            this.mContentWrapper.getViewTreeObserver().addOnPreDrawListener(this.mOnPreDrawListener);
        }
    }

    final void b(int arg3) {
        this.mAdTv.setTextColor(this.mResources.getColor(arg3));
        this.mAdTv.setTextSize(14f);
    }

    public final boolean d() {
        return this.U;
    }

    public final void e() {
        this.U = false;
    }

    public final void loadImage() {
        ImageInfo v0 = ArticleHelper.getImageInfoTag(this.mLargeImage);
        if (v0 != null) {
            android.support.design.a.setImage(this.mLargeImage, v0);
            this.mLargeImage.setTag(com.ss.android.article.browser.R.id.image_info, null);
        }
    }

    private void g() {
        if (this.mAdLargeImageLayout != null) {
            ((NightModeAsyncImageView) this.mLargeImage).adaptNightMode(this.M);
            this.mAdTitle.setTextColor(ContextCompat.getColorStateList(this.mContext, com.ss.android.article.browser.R.color.ssxinzi10));
            this.mCoverTopShaow.setBackgroundResource(com.ss.android.article.browser.R.drawable.thr_shadow_video);
        }

        if (this.mAdBottomLayout != null) {
            this.mAdAvatar.setColorFilter(this.aa);
            this.mAdAvatarTv.setTextColor(ContextCompat.getColor(this.mContext, com.ss.android.article.browser.R.color.ssxinzi7));
            this.mAdAvatarTv.setBackgroundResource(com.ss.android.article.browser.R.drawable.circle_solid_mian7);
            this.mAdSourceTvName.setTextColor(ContextCompat.getColorStateList(this.mContext, com.ss.android.article.browser.R.color.yp));
        }
    }

    public final void onMovedToScrapHeap() {
        TouchDelegate v5 = null;
        int v4 = 8;
        this.Y = false;
        this.mContentWrapper.getViewTreeObserver().removeOnPreDrawListener(this.mOnPreDrawListener);
        this.mContentWrapper.setTouchDelegate(v5);
        try {
            if (this.Z != null && this.Z.getStatus() != AsyncTask.Status.FINISHED) {
                this.Z.cancel(true);
            }

            if (this.B == null) {
            } else {
                DownloadAdapterProxy.inst().unregisterDownloadListener(this.mContext, Long.valueOf(this.B.id), this.N);
            }
        } catch (Exception v0) {
        }

        this.U = false;
        AdItemInVideoFeedViewHolder.a(this.mRoot, ((View.OnClickListener) v5));
        AdItemInVideoFeedViewHolder.a(this.mAdBtnLayout, ((View.OnClickListener) v5));
        UIUtils.setVisibility(this.mAdBtnLayout, v4);
        UIUtils.setVisibility(this.mAdLargeImageLayout, v4);
        UIUtils.setVisibility(this.mAppAdProgress, v4);
        UIUtils.setVisibility(this.mCoverTopShaow, v4);
        AsyncImageView v0_1 = this.mLargeImage;
        android.support.design.a.removeImageInfoTag(((ImageView) v0_1));
        if (v0_1 != null) {
            ((ImageView) v0_1).setImageDrawable(((Drawable) null));
        }
    }
}

